# critique to photo
class Critique < ActiveRecord::Base
  has_many :replies
  has_many :critique_ratings
  belongs_to :user
  belongs_to :photo

  validates_inclusion_of :rate,
                      :in => -3..3,
                      :message => "Should be between -3 and 3"

  def get_rate
    @up_rate = 0
    @down_rate = 0
    critique_ratings.each do |cr|
      if cr.rate > 0 
        @up_rate += cr.rate
      end
      if cr.rate < 0
        @down_rate += cr.rate
      end
    end
    @up_rate + @down_rate
  end

  def get_up_rate
    @up_rate
  end

  def get_down_rate
    @down_rate
  end
  
end
